var name = document.getElementById('name').value;


(function f958() {
    $.ajax({
        url: 'http://localhost:8080/985',
        type: 'get',
        dataType: 'json',
        success: function (res) {
            // var name = [];
            var r = [];
            // var results = []
            for (let i = 0; i < res.length; i++) {
                // name[i]= res[i]["name"]
                r[i] = res[i]['counts']

            }
            console.log(r);
            $('#985').text(r);
        }
    });
    $.ajax({
        url: 'http://localhost:8080/211',
        type: 'get',
        dataType: 'json',
        success: function (res) {
            // var name = [];
            var r = [];
            // var results = []
            for (let i = 0; i < res.length; i++) {
                // name[i]= res[i]["name"]
                r[i] = res[i]['counts']

            }
            $('#211').text(r);
        }
    });
}) ();

console.log(name);
(function ScholName() {
    var myChart = echarts.init(document.querySelector(".pie .chart"));
    var option = {
        title:{
            left:"center"
        },
        series: [
            {
                type:'pie',
                center: ['15%', '25%'],
                radius: ['50%', '40%'],
                itemStyle:{
                    color:"#669966"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}",
                        rich: {
                            b: {
                                fontSize:16,
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                    //图一
                ]
            },
            {
                type:'pie',
                center: ['35%', '60%'],
                radius: ['50%', '58%'],
                itemStyle:{
                    color:"#199ED8"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}",
                        rich: {
                            b: {
                                fontSize:16,
                                fontWeight:"bold",
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                ]
            },
            {
                type:'pie',
                center: ['65%', '60%'],
                radius: ['50%', '58%'],
                itemStyle:{
                    color:"#199ED8"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}",
                        rich: {
                            b: {
                                fontSize:14,
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                ]
            },
            {
                type:'pie',
                center: ['85%', '25%'],
                radius: ['50%', '40%'],
                itemStyle:{
                    color:"#FF9966"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}",
                        rich: {
                            b: {
                                fontSize:14,
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                ]
            }
        ]
    };
    $.ajax({
        // url: 'http://localhost:8080/name1/清华大学',
        url: 'http://localhost:8080/name1/'+name,
        type: 'get',
        dataType: 'json',
        success: function (res) {
            var stu = [];
            var life = [];
            var jiuye = [];
            var zh = [];
            var name = [];
            var results1 = []
            var results2 = []
            var results3 = []
            var results4 = []
            for (let i = 0; i < res.length; i++) {
                stu[i] = res[i]["stu"]
                life[i] = res[i]["life"]
                jiuye[i] = res[i]["jiuye"]
                zh[i] = res[i]["zh"]
                name[i] = res[i]["name"]
                results1.push({value: stu[i], name: '学习指数'})
                results2.push({value: life[i], name: '生活指数'})
                results3.push({value: jiuye[i], name: '就业指数'})
                results4.push({value: zh[i], name: '综合评分'})

            }
            console.log(results1);
            option.series[0].data = results1;
            // option.title.text = name;
            option.series[1].data = results2;
            option.series[2].data = results3;
            option.series[3].data = results4;
            myChart.setOption(option);
        }
    });

    myChart.setOption(option);
    window.addEventListener("resize", function () {
        myChart.resize();
    })
}) ();

/*
* 院系口碑
* */
(function koubei() {

    $.ajax({
        url: 'http://localhost:8080/name1/'+name,
        type: 'get',
        dataType: 'json',
        success: function (res) {
            var ts = [];
            var kb = [];
            var results = []
            for (let i = 0; i < res.length; i++) {
                ts[i]= res[i]["ts"]
                kb[i] = res[i]['kb']
                results = kb[i].split('---')
                for (let t= 0;t<results.length;t++){
                    $('#No'+t).text('-----:'+results[t]);
                }
            if (ts[0] !== ""){
                $('#ts').text(ts);
            }else {
                $('#ts').text("无");
            }
                console.log(ts)
            }
        }
    });

}) ();



(function fnv() {
    var myChart = echarts.init(document.querySelector(".pie2 .chart"));
    var option = {
        title:{
            left:"center"
        },
        series: [
            {
                type:'pie',
                center: ['25%', '40%'],
                radius: ['50%', '58%'],
                itemStyle:{
                    color:"#199ED8"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}%",
                        rich: {
                            b: {
                                fontSize:16,
                                fontWeight:"bold",
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                ]
            },
            {
                type:'pie',
                center: ['75%', '40%'],
                radius: ['50%', '58%'],
                itemStyle:{
                    color:"#199ED8"
                },
                label: {
                    normal: {
                        show: true,
                        position: 'center',
                        formatter: "{b|{b}}\n{b|{c}}%",
                        rich: {
                            b: {
                                fontSize:14,
                                lineHeight: 20,
                                align: 'center'
                            },
                        }
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '14',
                        }
                    }
                },
                data:[
                ]
            }
        ]
    };
    $.ajax({
        // url: 'http://localhost:8080/name1/清华大学',
        url: 'http://localhost:8080/name1/'+name,
        type: 'get',
        dataType: 'json',
        success: function (res) {
            var nv = [];
            var n = [];
            var v = [];
            var results1 = [];
            var results2 = [];
            for (let i = 0; i < res.length; i++) {
                n[i] = res[i]["nv"].split(":")[0].replace('%', '')
                v[i] = res[i]["nv"].split(":")[1].replace('%', '')
                results1.push({value: n[i], name: '男'})
                results2.push({value: v[i], name: '女'})
            }
            console.log(n)
            option.series[0].data = results1;
            // option.title.text = ;
            option.series[1].data = results2;

            myChart.setOption(option);
        }
    });

    myChart.setOption(option);
    window.addEventListener("resize", function () {
        myChart.resize();
    })
}) ();


(function Wline() {
    // 实例化对象
    var myChart = echarts.init(document.querySelector(".line .chart"));
    // 指定配置和数据
    var option = {
        color: ["#00f2f1", "#ed3f35", "#7171C6"],
        tooltip: {
            trigger: "axis",
            axisPointer: {
                // 坐标轴指示器，坐标轴触发有效
                type: "shadow" // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid: {
            left: "0%",
            top: "10px",
            right: "0%",
            bottom: "4%",
            containLabel: true
        },
        xAxis: {
            type: 'category',
            // 去除刻度
            axisTick: {
                show: false
            },
            // 修饰刻度标签的颜色
            axisLabel: {
                color: "rgba(255,255,255,.7)"
            },
            // 去除x坐标轴的颜色
            axisLine: {
                show: false
            },
            name: "年份",
            data: []
        },
        yAxis:  [{
            type: "value",
            // 去除刻度
            axisTick: {
                show: false
            },
            // 修饰刻度标签的颜色
            axisLabel: {
                show: true,
                color: "rgba(255,255,255,.7)",
                formatter: function (value) {
                    if (value >= 1000) {
                        value = value / 10000 + 'w';
                    }
                    return value;
                },
            },
            // 修改y轴分割线的颜色
            splitLine: {
                lineStyle: {
                    color: "#012f4a"
                }
            }
        }],
        series: [
            {
                name: "理科",
                type: 'line',
                smooth: true,
                data: []
            },{
                name: "文科",
                type: 'line',
                smooth: true,
                data: []
            }
        ]
    };
    $.ajax({
        url: 'http://localhost:8080/w/'+name,
        type: 'get',
        dataType: 'json',
        success: function (res) {
            var time = [];
            var minScore = [];
            // var results = []
            for (let i = 0; i < res.length; i++) {
                time[i] = res[i]["time"]
                minScore[i] = res[i]["minScore"]

                // results.push({name: time[i], value: grade1[i]})
            }
            console.log(time);
            // console.log(grade1);
            option.xAxis.data = time;
            option.series[1].data = minScore;
            myChart.setOption(option);
        }
    });
    $.ajax({
        url: 'http://localhost:8080/l/'+name,
        type: 'get',
        dataType: 'json',
        success: function (res) {
            var time = [];
            var minScore = [];
            // var results = []
            for (let i = 0; i < res.length; i++) {
                time[i] = res[i]["time"]
                minScore[i] = res[i]["minScore"]

                // results.push({name: time[i], value: grade1[i]})
            }
            console.log(time);
            // console.log(grade1);
            option.xAxis.data = time;
            option.series[0].data = minScore;
            myChart.setOption(option);
        }
    });

    // option.xAxis[0].data = time;
    // option.series[0].data = grade;
    // // 把配置给实例对象
    // myChart.setOption(option);
    window.addEventListener("resize", function () {
        myChart.resize();
    })
}) ();